# -*- coding: utf-8 -*-
# 读写2003 excel
import xlrd
import re
import requests 

def find_last(string,str):
  last_position=-1
  while True:
    position=string.find(str,last_position+1)
    if position==-1:
      return last_position
    last_position=position

def download(url,path):
  r = requests.get(url) 
  with open(path, "wb") as code:
    code.write(r.content)


workbook = xlrd.open_workbook("F:\\无标题.xls")
table=workbook.sheet_by_name('Sheet1')

nrows=table.nrows
for i in range(nrows):
  row = table.row_values(i)
  if i<1:
    print("-- ----------Sheet1-")
  else:
    j=0;
    audio_url='';
    for cell in row:
      cell=str(cell).replace("\n", "").replace("\r","").replace("\u200B","").replace("http://resource.helloprincess62.top","").strip()
      if j==3:
        audio_url =  cell;
      j=j+1;
    if(len(audio_url)>0):
      name = audio_url[find_last(audio_url,"/")+1:]
      print("http://resource.helloprincess62.top"+audio_url)
      download("http://resource.helloprincess62.top"+audio_url,"F:\\tcp\\"+name)
  i=i+1


